<extend name="Layout/ins_home" />
<block name="content">
	<div class="row" id="sortable-view">
		<div class="col-sm-6 ui-sortable" id="t1">
			<div class="ibox" sort="11">
				<div class="ibox-title">
					<h5>邮件</h5>
					<div class="ibox-tools">
						<ul class="nav nav-tabs" id="myTab">
							<li class="active">
								<a data-toggle="tab" href="#mail-new">最新</a>
							</li>
							<li>
								<a data-toggle="tab" href="#mail-unread">未读</a>
							</li>
						</ul>
					</div>
				</div>
				<div class="ibox-content">
					<div class="tab-content">
						<div id="mail-new" class="tab-pane in active ul_table">
							<ul>
								<volist name="new_mail_list" id="vo">
									<li>
										<span class="pull-right hidden-xs">{$vo.create_time|to_date='Y-m-d'}</span>
										<span  class="auto autocut"> <a href="{:U('mail/read','id='.$vo['id'])}&return_url=Mail/folder?fid=inbox" >{$vo.name|default="无标题"}</a> </span>
									</li>
								</volist>
							</ul>
						</div>
						<div id="mail-unread" class="tab-pane ul_table">
							<ul>
								<volist name="unread_mail_list" id="vo">
									<li>
										<span class="pull-right hidden-xs">{$vo.create_time|to_date='Y-m-d '}</span>
										<span  class="auto autocut"> <a href="{:U('mail/read','id='.$vo['id'])}&return_url=Mail/folder?fid=inbox" node="85" return_url="{:U('mail/folder/','fid=inbox')}" onclick="click_home_list(this)">{$vo.name|default="无标题"}</a> </span>
									</li>
								</volist>
							</ul>
						</div>
					</div>
				</div>
			</div>
			<div class="ibox" sort="12">
				<div class="ibox-title">
					<h5>信息</h5>
				</div>
				<div class="ibox-content">
					<div class="ul_table widget-main">
						<ul>
							<volist name="info_list" id="vo">
								<li>
									<span class="pull-right hidden-xs">{$vo.create_time|to_date='Y-m-d '}</span>
									<span class="auto autocut"><a href="{:U('info/read','id='.$vo['id'])}&return_url=Info/index" >【{$vo.folder_name}】{$vo.name}</a> </span>
								</li>
							</volist>
						</ul>
					</div>
				</div>
			</div>
		</div>
		<div class="col-sm-6 ui-sortable" id="t2">
			<div class="ibox" sort="21">
				<div class="ibox-title">
					<h5>审批</h5>
					<div class="ibox-tools">
						<ul class="nav nav-tabs" id="myTab">
							<li class="active">
								<a data-toggle="tab" href="#flow-todo">待办</a>
							</li>
							<li>
								<a data-toggle="tab" href="#flow-submit">已提交</a>
							</li>
						</ul>
					</div>
				</div>
				<div class="ibox-content">
					<div class="tab-content">
						<div id="flow-todo" class="tab-pane in active ul_table">
							<ul>
								<volist name="todo_flow_list" id="vo">
									<li>
										<span class="pull-right hidden-xs">{$vo.create_time|to_date='Y-m-d'}</span>
										<span  class="auto autocut"> <a href="{:U('flow/read','id='.$vo['id'].'&fid=confirm')}&return_url=Flow/folder?fid=confirm" >{$vo.name}</a> </span>
									</li>
								</volist>
							</ul>
						</div>
						<div id="flow-submit" class="tab-pane ul_table">
							<ul>
								<volist name="submit_flow_list" id="vo">
									<li>
										<span class="pull-right hidden-xs">{$vo.create_time|to_date='Y-m-d'}</span>
										<span  class="auto autocut"> <a href="{:U('flow/read','id='.$vo['id'].'&fid=submit')}&return_url=Flow/folder?fid=submit" >{$vo.name}</a> </span>
									</li>
								</volist>
							</ul>
						</div>
					</div>
				</div>
			</div>
			<div class="ibox" sort="22">
				<div class="ibox-title">
					<h5>日程</h5>
					<div class="ibox-tools">
						<ul class="nav nav-tabs" id="myTab">
							<li class="active">
								<a data-toggle="tab" href="#calendar-todo">待办</a>
							</li>
							<li>
								<a data-toggle="tab" href="#calendar-schedule">日程</a>
							</li>
						</ul>
					</div>
				</div>
				<div class="ibox-content">
					<div class="tab-content">
						<div id="calendar-schedule" class=" ul_table tab-pane ">
							<ul>
								<volist name="schedule_list" id="vo">
									<li>
										<span class="pull-right hidden-xs">{$vo.start_time|substr=0,10}</span>
										<span  class="auto autocut"> <a href="{:U('schedule/read2','id='.$vo['id'])}&return_url=Schedule/index" >{$vo.name}</a></span>
									</li>
								</volist>
							</ul>
						</div>
						<div id="calendar-todo" class=" ul_table active tab-pane">
							<ul>
								<volist name="todo_list" id="vo">
									<li>
										<span class="pull-right hidden-xs">{$vo.end_date}</span>
										<span  class="auto autocut"> <a href="{:U('todo/edit','id='.$vo['id'])}&return_url=Todo/index">{$vo.name}</a> </span>
									</li>
								</volist>
							</ul>
						</div>
					</div>
				</div>
			</div>
		</div>
	</div>
</block>
<block name="js">
	<script type="text/javascript">
		$(function() {
			if (!is_mobile()) {
				WinMove();
			}
			init_sort("{$home_sort}");
		});

		function init_sort(sort_string) {
			if (sort_string == "") {
				sort_string = "11,12,13|21,22,23";
			}
			array_sort_string = sort_string.split("|");
			sort_string_1 = array_sort_string[0];
			sort_string_2 = array_sort_string[1];
			array_sort = sort_string_1.split(",");

			for (x in array_sort) {
				index = array_sort[x];
				last = $("#t1 .ibox:last");
				current = $(".ibox[sort='" + index + "']");
				if (index !== last.attr("sort")) {
					current.insertAfter(last);
				}
			}

			array_sort = sort_string_2.split(",");
			for (x in array_sort) {
				index = array_sort[x];
				last = $("#t2 .ibox:last");
				current = $(".ibox[sort='" + index + "']");
				if (index !== last.attr("sort")) {
					current.insertAfter(last);
				}
			}
		};
		function set_sort() {
			var sort_string;
			$("#t1 .ibox").each(function() {
				sort_string = sort_string + $(this).attr("sort") + ",";
			});
			sort_string = sort_string + "|";
			$("#t2 .ibox").each(function() {
				sort_string = sort_string + $(this).attr("sort") + ",";
			});
			sendAjax("{:U('set_sort')}", "val=" + sort_string);
		}

		// Dragable panels
		function WinMove() {
			var element = "[class*=col]";
			var handle = ".ibox-title";
			var connect = "[class*=col]";
			$(element).sortable({
				handle : handle,
				connectWith : connect,
				cancel : ".ibox-tools",
				tolerance : 'pointer',
				forcePlaceholderSize : true,
				opacity : 0.8,
				stop : function(event, ui) {
					t1_count = $("#t1 .ibox").length;
					t2_count = $("#t2 .ibox").length;
					if ((t1_count == 0) || (t2_count == 0)) {
						ui_error("至少保留一个");
						$(element).sortable('cancel');
						return false;
					} else {
						set_sort();
					}
				}
			}).disableSelection();
		}
	</script>
</block>